{{extend ('./layout.html')}}

{{#block ("body")}}
{{extend ('./menu.html')}}
<style>
	.btn{
		width: 60px;
		height: 30px;
		padding: 0;
	}
	#dataTable tbody td{
		line-height: 30px;
	}
</style>
<div class="main-container">
	<div class="padding-md">
		<ul class="breadcrumb">
			<li><span class="primary-font"><i class="icon-home"></i></span><a href="/home/index"> 首页</a></li>
			<li>账号列表</li>
		</ul>
		{{#if(checkAction('userAdd'))}}
		<button onclick="location.href='/user/userAdd';" type="button" class="btn btn-success btn-sm">添加账号</button>
		{{/if}}
		<table class="table table-striped" id="dataTable">
			<thead>
			<tr>
				<th>ID</th>
				<th>账号名称</th>
				<th>账号邮箱</th>
				<th>创建时间</th>
				<th>账号登录次数</th>
				<th>账号类型</th>
				<th>操作</th>
			</tr>
			</thead>
			<tbody>
			{{#each(array)}}
			<tr>
				<td>{{this.user_id}}</td>
				<td>{{this.user_name}}</td>
				<td>{{this.user_email?this.user_email:"无邮箱地址"}}</td>
				<td>{{this.user_time?this.moment(this.user_time).format('YYYY MM DD, h:mm:ss'):"无创建时间"}}</td>
				<td>{{this.user_login_count?this.user_login_count:"未登陆"}}</td>
				<td>{{this.type_name}}</td>
				<td>
					{{#if(this.checkAction('userEdit'))}}
					<a href="/user/userEdit?user_id={{this.user_id}}"><input type="button" value="编辑" class="btn btn-success" ></a>
					{{/if}}
					{{#if(this.checkAction('userDelete'))}}
					<a href="javascript:;"><input type="button" onclick="isDelete({{this.user_id}})" value="删除" class="btn btn-danger"></a>
					{{/if}}
					{{#if(this.checkAction('userAction'))}}
					<a href="/user/userAction?user_id={{this.user_id}}"><input type="button" value="权限"  class="btn btn-warning"></a>
					{{/if}}
				</td>
			</tr>
			{{/each}}

			</tbody>
		</table>

		<ul class="pagination">

			<!--上翻页-->
			{{#if( page<=1 )}}
			<li class="disabled">
				<a>
					<span>&laquo;</span>
				</a>
			</li>
			{{else}}
			<li>
				<a href="/user/userList?page={{page-1}}" aria-label="Previous">
					<span aria-hidden="true">&laquo;</span>
				</a>
			</li>
			{{/if}}

			<!--中间页码-->
			{{#each(totalPageArray)}}
			{{#if(page===this)}}
				<li class="active"><a>{{this}}</a></li>
			{{else}}
				<li>
					<a href="/user/userList?page={{this}}">{{this}}</a>
				</li>
			{{/if}}
			{{/each}}


			<!--下翻页-->
			{{#if(page >= totalPage)}}
			<li class="disabled">
				<a aria-label="Next">
					<span aria-hidden="true">&raquo;</span>
				</a>
			</li>
			{{else}}
			<li>
				<a href="/user/userList?page={{page+1}}" aria-label="Next">
					<span aria-hidden="true">&raquo;</span>
				</a>
			</li>
			{{/if}}



		</ul>
	</div><!-- ./padding-md -->
</div><!-- /main-container -->
<script>
	var isDelete = function(user_id){
		if(confirm("删除是不可恢复的，你确认要删除吗？")){
			window.location.href="/user/userDelete?user_id=" + user_id;
			return false;
		} else{
			return false;
		}		 
	}
</script>
{{/block}}